<!DOCTYPE html>
<html>
<!-- Created by GNU Texinfo 7.1.1, https://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- Copyright © 1988-2023 Free Software Foundation, Inc.

Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with the
Invariant Sections being "Funding Free Software", the Front-Cover
Texts being (a) (see below), and with the Back-Cover Texts being (b)
(see below).  A copy of the license is included in the section entitled
"GNU Free Documentation License".

(a) The FSF's Front-Cover Text is:

A GNU Manual

(b) The FSF's Back-Cover Text is:

You have freedom to copy and modify this GNU Manual, like GNU
     software.  Copies published by the Free Software Foundation raise
     funds for GNU development. -->
<title>Floating Point (GNU Compiler Collection (GCC) Internals)</title>

<meta name="description" content="Floating Point (GNU Compiler Collection (GCC) Internals)">
<meta name="keywords" content="Floating Point (GNU Compiler Collection (GCC) Internals)">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta name="viewport" content="width=device-width,initial-scale=1">

<link href="index.html" rel="start" title="Top">
<link href="Option-Index.html" rel="index" title="Option Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="Target-Macros.html" rel="up" title="Target Macros">
<link href="Mode-Switching.html" rel="next" title="Mode Switching">
<link href="Debugging-Info.html" rel="prev" title="Debugging Info">
<style type="text/css">
<!--
a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
span:hover a.copiable-link {visibility: visible}
strong.def-name {font-family: monospace; font-weight: bold; font-size: larger}
-->
</style>


</head>

<body lang="en">
<div class="section-level-extent" id="Floating-Point">
<div class="nav-panel">
<p>
Next: <a href="Mode-Switching.html" accesskey="n" rel="next">Mode Switching Instructions</a>, Previous: <a href="Debugging-Info.html" accesskey="p" rel="prev">Controlling Debugging Information Format</a>, Up: <a href="Target-Macros.html" accesskey="u" rel="up">Target Description Macros and Functions</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<h3 class="section" id="Cross-Compilation-and-Floating-Point"><span>18.22 Cross Compilation and Floating Point<a class="copiable-link" href="#Cross-Compilation-and-Floating-Point"> &para;</a></span></h3>
<a class="index-entry-id" id="index-cross-compilation-and-floating-point"></a>
<a class="index-entry-id" id="index-floating-point-and-cross-compilation"></a>

<p>While all modern machines use twos-complement representation for integers,
there are a variety of representations for floating point numbers.  This
means that in a cross-compiler the representation of floating point numbers
in the compiled program may be different from that used in the machine
doing the compilation.
</p>
<p>Because different representation systems may offer different amounts of
range and precision, all floating point constants must be represented in
the target machine&rsquo;s format.  Therefore, the cross compiler cannot
safely use the host machine&rsquo;s floating point arithmetic; it must emulate
the target&rsquo;s arithmetic.  To ensure consistency, GCC always uses
emulation to work with floating point values, even when the host and
target floating point formats are identical.
</p>
<p>The following macros are provided by <samp class="file">real.h</samp> for the compiler to
use.  All parts of the compiler which generate or optimize
floating-point calculations must use these macros.  They may evaluate
their operands more than once, so operands must not have side effects.
</p>
<dl class="first-deffn first-defmac-alias-first-deffn">
<dt class="deffn defmac-alias-deffn" id="index-REAL_005fVALUE_005fTYPE"><span class="category-def">Macro: </span><span><strong class="def-name">REAL_VALUE_TYPE</strong><a class="copiable-link" href="#index-REAL_005fVALUE_005fTYPE"> &para;</a></span></dt>
<dd><p>The C data type to be used to hold a floating point value in the target
machine&rsquo;s format.  Typically this is a <code class="code">struct</code> containing an
array of <code class="code">HOST_WIDE_INT</code>, but all code should treat it as an opaque
quantity.
</p></dd></dl>

<dl class="first-deftypefn">
<dt class="deftypefn" id="index-REAL_005fVALUE_005fFIX"><span class="category-def">Macro: </span><span><code class="def-type">HOST_WIDE_INT</code> <strong class="def-name">REAL_VALUE_FIX</strong> <code class="def-code-arguments">(REAL_VALUE_TYPE <var class="var">x</var>)</code><a class="copiable-link" href="#index-REAL_005fVALUE_005fFIX"> &para;</a></span></dt>
<dd><p>Truncates <var class="var">x</var> to a signed integer, rounding toward zero.
</p></dd></dl>

<dl class="first-deftypefn">
<dt class="deftypefn" id="index-REAL_005fVALUE_005fUNSIGNED_005fFIX"><span class="category-def">Macro: </span><span><code class="def-type">unsigned HOST_WIDE_INT</code> <strong class="def-name">REAL_VALUE_UNSIGNED_FIX</strong> <code class="def-code-arguments">(REAL_VALUE_TYPE <var class="var">x</var>)</code><a class="copiable-link" href="#index-REAL_005fVALUE_005fUNSIGNED_005fFIX"> &para;</a></span></dt>
<dd><p>Truncates <var class="var">x</var> to an unsigned integer, rounding toward zero.  If
<var class="var">x</var> is negative, returns zero.
</p></dd></dl>

<dl class="first-deftypefn">
<dt class="deftypefn" id="index-REAL_005fVALUE_005fATOF"><span class="category-def">Macro: </span><span><code class="def-type">REAL_VALUE_TYPE</code> <strong class="def-name">REAL_VALUE_ATOF</strong> <code class="def-code-arguments">(const char *<var class="var">string</var>, machine_mode <var class="var">mode</var>)</code><a class="copiable-link" href="#index-REAL_005fVALUE_005fATOF"> &para;</a></span></dt>
<dd><p>Converts <var class="var">string</var> into a floating point number in the target machine&rsquo;s
representation for mode <var class="var">mode</var>.  This routine can handle both
decimal and hexadecimal floating point constants, using the syntax
defined by the C language for both.
</p></dd></dl>

<dl class="first-deftypefn">
<dt class="deftypefn" id="index-REAL_005fVALUE_005fNEGATIVE"><span class="category-def">Macro: </span><span><code class="def-type">int</code> <strong class="def-name">REAL_VALUE_NEGATIVE</strong> <code class="def-code-arguments">(REAL_VALUE_TYPE <var class="var">x</var>)</code><a class="copiable-link" href="#index-REAL_005fVALUE_005fNEGATIVE"> &para;</a></span></dt>
<dd><p>Returns 1 if <var class="var">x</var> is negative (including negative zero), 0 otherwise.
</p></dd></dl>

<dl class="first-deftypefn">
<dt class="deftypefn" id="index-REAL_005fVALUE_005fISINF"><span class="category-def">Macro: </span><span><code class="def-type">int</code> <strong class="def-name">REAL_VALUE_ISINF</strong> <code class="def-code-arguments">(REAL_VALUE_TYPE <var class="var">x</var>)</code><a class="copiable-link" href="#index-REAL_005fVALUE_005fISINF"> &para;</a></span></dt>
<dd><p>Determines whether <var class="var">x</var> represents infinity (positive or negative).
</p></dd></dl>

<dl class="first-deftypefn">
<dt class="deftypefn" id="index-REAL_005fVALUE_005fISNAN"><span class="category-def">Macro: </span><span><code class="def-type">int</code> <strong class="def-name">REAL_VALUE_ISNAN</strong> <code class="def-code-arguments">(REAL_VALUE_TYPE <var class="var">x</var>)</code><a class="copiable-link" href="#index-REAL_005fVALUE_005fISNAN"> &para;</a></span></dt>
<dd><p>Determines whether <var class="var">x</var> represents a &ldquo;NaN&rdquo; (not-a-number).
</p></dd></dl>

<dl class="first-deftypefn">
<dt class="deftypefn" id="index-REAL_005fVALUE_005fNEGATE"><span class="category-def">Macro: </span><span><code class="def-type">REAL_VALUE_TYPE</code> <strong class="def-name">REAL_VALUE_NEGATE</strong> <code class="def-code-arguments">(REAL_VALUE_TYPE <var class="var">x</var>)</code><a class="copiable-link" href="#index-REAL_005fVALUE_005fNEGATE"> &para;</a></span></dt>
<dd><p>Returns the negative of the floating point value <var class="var">x</var>.
</p></dd></dl>

<dl class="first-deftypefn">
<dt class="deftypefn" id="index-REAL_005fVALUE_005fABS"><span class="category-def">Macro: </span><span><code class="def-type">REAL_VALUE_TYPE</code> <strong class="def-name">REAL_VALUE_ABS</strong> <code class="def-code-arguments">(REAL_VALUE_TYPE <var class="var">x</var>)</code><a class="copiable-link" href="#index-REAL_005fVALUE_005fABS"> &para;</a></span></dt>
<dd><p>Returns the absolute value of <var class="var">x</var>.
</p></dd></dl>

</div>
<hr>
<div class="nav-panel">
<p>
Next: <a href="Mode-Switching.html">Mode Switching Instructions</a>, Previous: <a href="Debugging-Info.html">Controlling Debugging Information Format</a>, Up: <a href="Target-Macros.html">Target Description Macros and Functions</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html" title="Index" rel="index">Index</a>]</p>
</div>



</body>
</html>
